var list = require('../../data/word-list.js')
const pageData = {
  data: {
    exp:0,
    rank:0,
    word: []
  },
  onLoad: function (options) {
    //for(var idx=0;idx<2;idx++){
    var exp1 = wx.getStorageSync('exp');
    var rank1 = wx.getStorageSync('rank');
      this.setData({ 'exp': exp1 });
      this.setData({ 'rank':  rank1});

  },
  //再来一局
  goToWordlist: function () {

    console.log(getApp().data.selectnum)
    if (getApp().data.selectnum == 1) {
      console.log(1111);
     this.toGoSimple();
    }
    if (getApp().data.selectnum == 2) {
      this.toGoCommonly;
    }
    if (getApp().data.selectnum == 3) {
      this.toGoHard();
    }
  },
  toGoSimple: function () {
    getApp().data.selectnum = 1;
    console.log(getApp().data.selectnum)
    for (var i = 0; i < 16; i++) {
      var word = list.wordList[i]
      this.setData({ ['word[' + i + '].text']: word.content });
      i++;
      this.setData({ ['word[' + i + '].text']: word.definition });
    }
    this.setWord();
    wx.redirectTo({
      url: '../wordlist1/wordlist1'
    });
  },
  //跳转到一般学习界面
  toGoCommonly: function () {
    getApp().data.selectnum = 2;
    for (var i = 0; i < 16; i++) {
      var word = list.wordList[i]
      this.setData({ ['word[' + i + '].text']: word.content });
      i++;
      this.setData({ ['word[' + i + '].text']: word.definition });
    }
    this.setWord();
    wx.redirectTo({
      url: '../wordlist1/wordlist1'
    });
  },
  //跳转到困难学习界面
  toGoHard: function () {
    getApp().data.selectnum = 3;
    for (var i = 0; i < 16; i++) {
      var word = list.wordList[i]
      this.setData({ ['word[' + i + '].text']: word.content });
      i++;
      this.setData({ ['word[' + i + '].text']: word.definition });
    }
    this.setWord();
    wx.redirectTo({
      url: '../wordlist1/wordlist1'
    });
  },
  goToRule: function () {
    wx.redirectTo({
      url: '../rule/rule'
    });
  },
  setWord: function () {
    wx.setStorageSync('1', this.data.word[0].text),
      wx.setStorageSync('2', this.data.word[2].text),
      wx.setStorageSync('3', this.data.word[4].text),
      wx.setStorageSync('4', this.data.word[6].text),
      wx.setStorageSync('5', this.data.word[8].text),
      wx.setStorageSync('6', this.data.word[10].text),
      wx.setStorageSync('7', this.data.word[12].text),
      wx.setStorageSync('8', this.data.word[14].text),
      wx.setStorageSync('9', this.data.word[15].text),
      wx.setStorageSync('10', this.data.word[13].text),
      wx.setStorageSync('11', this.data.word[11].text),
      wx.setStorageSync('12', this.data.word[9].text),
      wx.setStorageSync('13', this.data.word[7].text),
      wx.setStorageSync('14', this.data.word[5].text),
      wx.setStorageSync('15', this.data.word[3].text),
      wx.setStorageSync('16', this.data.word[1].text)
  },
  //返回
  goToSelect: function () {
    wx.redirectTo({
      url: '../select/select'
    });
  },
}

Page(pageData);